#pragma once
#include <d3dx9.h>


class PARTICLEDATA
{
public:
	PARTICLEDATA()
	{
		reset_particle();
	}

	void render_particle();
	void set_particle(float camx, float camy, float camz);
	void run_particle(float seconds);
	void reset_particle();

	bool active; 

	void GetPos(float&x, float&y, float&z);
	void SetPos(const float x,const float y, const float z);
	void GetVelocity(float&x, float&y, float&z);
	void SetVelocity(const float x,const float y, const float z);
	void GetAcceleration(float&x, float&y, float&z);
	void SetAcceleration(const float x,const float y, const float z);
	float GetRadius();
	void SetRadius(const float fr);
	float GetLifeSpan();
	void SetLifeSpan(const float fr);
	float GetLife();
	void SetLife(const float fr);
	void SetTexture(void* pkTexture);
	void SetBuff(void* pktBuff,void* pkgBuff);
protected:
	D3DXVECTOR3 m_position;
	D3DXVECTOR3 m_velocity;
	D3DXVECTOR3 m_acceleration;
	float m_radius;
	float m_lifespan;
	float m_life;
	D3DXMATRIX m_matRotateX;
	D3DXMATRIX m_matRotateY;
	LPDIRECT3DTEXTURE9 m_ptexture;
	LPDIRECT3DVERTEXBUFFER9 t_pbuffer;    // the pointer to the particle's vertex buffer
	LPDIRECT3DVERTEXBUFFER9 g_pbuffer;    // the pointer to the grid's vertex buffer
};




class TwParticle
{
public:
	TwParticle(void);
	~TwParticle(void);

	void InitGraphics();

	void InitRenderState();

	void InitLight();

	void Update();

	void Render();

	void Clear();

	void run_particles();

	void render_grid();


	void GetPos(float&x, float&y, float&z);
	void SetPos(const float x,const float y, const float z);
	void GetVelocity(float&x, float&y, float&z);
	void SetVelocity(const float x,const float y, const float z);
	void GetAcceleration(float&x, float&y, float&z);
	void SetAcceleration(const float x,const float y, const float z);
	float GetRadius();
	void SetRadius(const float fr);
	float GetLifeSpan();
	void SetLifeSpan(const float fr);
	void reset_particle();
	void ResetData(PARTICLEDATA& data);
private:
	D3DXVECTOR3 m_position;
	D3DXVECTOR3 m_velocity;
	D3DXVECTOR3 m_acceleration;
	float m_radius;
	float m_lifespan;
	// PARTICLE particle;
	static const int PARTICLECOUNT = 300;
	PARTICLEDATA m_particle[PARTICLECOUNT]; 
	float m_camx, m_camy, m_camz;    // camera position
	LPDIRECT3DTEXTURE9 m_ptexture;

	LPDIRECT3DVERTEXBUFFER9 t_pbuffer;    // the pointer to the particle's vertex buffer
	LPDIRECT3DVERTEXBUFFER9 g_pbuffer;    // the pointer to the grid's vertex buffer
};
